<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let str = 'aakkssiwnfeubajjvjnebmeogssssssfududsdfjk'

        // 出现次数  n次
        function most(str) {
            let obj = {}
            for (var i of str) {
                if (i in obj) {
                    obj[i]++
                } else {
                    obj[i] = 1
                }
            }
            return obj
        }

        let fn = most(str)
        let keys = Object.keys(fn)

        let maxVal = Object.values(fn).sort((a, b) => a - b)[Object.values(fn).length - 1]
        let index = Object.values(fn).indexOf(maxVal)

        console.log(most(str));
        console.log(keys[index]);
        console.log(maxVal);
        
    </script>
</body>

</html>